package main

import (
	"fmt"
)

/**
 * defer延迟语句
 */
func main() {
	defer myfunc()
	fmt.Println("main")
	name := "go"
	defer fmt.Println(name)

	name = "java"
	fmt.Println(name)
	myname := myfunc01()
	fmt.Printf("main 函数里的name: %s\n", language)
	fmt.Println("main 函数里的myname: ", myname)
}

func myfunc() {
	fmt.Println("defer func")
}

var language string = "go"

func myfunc01() string {
	defer func() {
		language = "java"
	}()
	fmt.Printf("myfunc 函数里的name：%s\n", language)
	return language
}
